package ru.sviridov.sellandbuy.tools;

import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;

public abstract class Utils {
	
	public static String md5(String unsecuredString){
		try {
	        // Create MD5 Hash
	        MessageDigest digest = java.security.MessageDigest.getInstance("MD5");
	        digest.update(unsecuredString.getBytes());
	        byte messageDigest[] = digest.digest();
	 
	        // Create Hex String
	        StringBuilder hexString = new StringBuilder();
	        for (int i = 0; i < messageDigest.length; i++) {
	            String h = Integer.toHexString(0xFF & messageDigest[i]);
	            if(h.length() < 2)
	            	hexString.append("0");
	            hexString.append(h);
	        }
	        return hexString.toString();
	 
	    } catch (NoSuchAlgorithmException e) {
	        e.printStackTrace();
	    }
	    return "";
		
	}
}
